package cn.jbit.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jbit.news.dao.impl.NewsDaoImpl;
import org.jbit.news.entity.News;

@SuppressWarnings("serial")
public class sourchNews extends HttpServlet{

	@Override
	protected void service(HttpServletRequest arg0, HttpServletResponse arg1)
			throws ServletException, IOException {
		arg0.setCharacterEncoding("UTF-8");
		arg1.setContentType("text/html;charset=UTF-8");
		String sourch=arg0.getParameter("sourch");
		NewsDaoImpl nd=new NewsDaoImpl();
		List<News> newsList=nd.findByName(sourch);
		if(newsList!=null){
			arg0.getSession().setAttribute("list", newsList);
			arg1.sendRedirect("newspages/admin1.jsp");
		}else{
			arg1.sendRedirect("newspages/admin.jsp");
		}
	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		super.destroy();
	}

	@Override
	public void init() throws ServletException {
		// TODO Auto-generated method stub
		super.init();
	}

}
